<?php

return [
    // 启用插件
    'enable' => true,
    
    // gRPC配置
    'grpc' => [
        // 启用gRPC
        'enabled' => true,
        
        // 服务端配置
        'server' => [
            'host' => '0.0.0.0',
            'port' => 50051,
            'credentials' => null,  // SSL凭证
            'max_recv_msg_length' => 4194304,  // 4MB
            'max_send_msg_length' => 4194304,  // 4MB
        ],
        
        // 客户端配置
        'client' => [
            'timeout' => 30,  // 超时时间(秒)
            'credentials' => null,  // SSL凭证
            'max_recv_msg_length' => 4194304,  // 4MB
            'max_send_msg_length' => 4194304,  // 4MB
            'retry' => 3,  // 重试次数
            'backoff' => [  // 退避策略
                'initial' => 100,  // 初始延迟(毫秒)
                'max' => 1000,  // 最大延迟(毫秒)
                'multiplier' => 2,  // 延迟倍数
            ],
            'connection_pool' => [  // 连接池配置
                'max_connections' => 10,  // 最大连接数
                'idle_timeout' => 60,  // 空闲超时(秒)
                'max_lifetime' => 300,  // 最大生命周期(秒)
            ],
        ],
        
        // 注册的服务
        'services' => [
            // 示例服务
            'example.ExampleService' => [
                'class' => \WebmanGrpc\Examples\ExampleService::class,
                'options' => [],
            ],
        ],
        
        // 拦截器
        'interceptors' => [
            [
                'class' => \WebmanGrpc\Interceptor\LoggingInterceptor::class,
                'priority' => 100,
            ],
        ],
    ],
    
    // HTTP到gRPC网关配置
    'http_gateway' => [
        // 启用HTTP网关
        'enabled' => true,
        
        // 路由配置
        'routes' => [
            [
                'path' => '/api/example/simple',
                'method' => 'POST',
                'service' => 'example.ExampleService',
                'method' => 'SimpleMethod',
                'request_transformer' => \WebmanGrpc\Examples\Transformer\ExampleRequestTransformer::class,
                'response_transformer' => \WebmanGrpc\Examples\Transformer\ExampleResponseTransformer::class,
                'address' => '127.0.0.1:50051',
                'options' => [],
            ],
        ],
    ],
];